namespace Crux.Core.Data;
/// <summary>
/// OrderExpression
/// </summary>
public class OrderExpression<T>
{
    /// <summary>
    /// 
    /// </summary>
    public OrderSymbol Symbol { get; set; } = OrderSymbol.Asc;
    /// <summary>
    /// 
    /// </summary>
    public Expression<Func<T, object>>? Expression { get; set; }
    /// <summary>
    /// private .ctor
    /// </summary>
    /// <param name="expression"></param>
    /// <param name="symbol"></param>
    private OrderExpression(
        Expression<Func<T, object>> expression,
        OrderSymbol symbol = OrderSymbol.Asc)
    {
        if (expression is null)
        {
            throw new ArgumentNullException(nameof(expression));
        }

        Symbol = symbol;
        Expression = expression;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="expression"></param>
    /// <param name="symbol"></param>
    /// <returns></returns>
    public static OrderExpression<T> Create(Expression<Func<T, object>> expression, OrderSymbol symbol = OrderSymbol.Asc)
    {
        if (expression is null)
        {
            throw new ArgumentNullException(nameof(expression));
        }

        return new OrderExpression<T>(expression, symbol);
    }
}